package com.train.webadmin.app.model;

import com.baomidou.mybatisplus.annotation.*;
import com.train.common.core.annotation.*;
import lombok.Data;

import java.util.Date;
import java.util.Map;

/**
 * 试卷题目实体对象。
 *
 * @author xulei
 * @date 2025-03-07
 */
@Data
@TableName(value = "t_question_info")
public class TQuestionInfo {

    /**
     * 题目id。
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 课程id。
     */
    @TableField(value = "course_id")
    private Long courseId;

    /**
     * 试卷id。
     */
    @TableField(value = "paper_id")
    private Long paperId;

    /**
     * 题干。
     */
    @TableField(value = "title")
    private String title;

    /**
     * 类型。
     */
    @TableField(value = "types")
    private Integer types;

    /**
     * 解析。
     */
    @TableField(value = "remark")
    private String remark;

    /**
     * 分数。
     */
    @TableField(value = "score")
    private Double score;

    /**
     * 难度。
     */
    @TableField(value = "degree")
    private Integer degree;

    /**
     * 创建时间。
     */
    @TableField(value = "create_time")
    private Date createTime;

    /**
     * 更新时间。
     */
    @TableField(value = "update_time")
    private Date updateTime;

    /**
     * 创建人id。
     */
    @TableField(value = "create_user_id")
    private Long createUserId;

    /**
     * 修改人id。
     */
    @TableField(value = "update_user_id")
    private Long updateUserId;

    /**
     * 逻辑删除标记字段(1: 正常 -1: 已删除)。
     */
    @TableLogic
    @TableField(value = "deleted_flag")
    private Integer deletedFlag;

    /**
     * 正确答案。
     */
    @TableField(value = "correct_answer")
    private String correctAnswer;

    /**
     * 选项。
     */
    @TableField(value = "options")
    private String options;

    @RelationOneToOne(
            masterIdField = "courseId",
            slaveModelClass = CourseInfo.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private CourseInfo courseInfo;

    @RelationDict(
            masterIdField = "courseId",
            equalOneToOneRelationField = "courseInfo",
            slaveModelClass = CourseInfo.class,
            slaveIdField = "id",
            slaveNameField = "title")
    @TableField(exist = false)
    private Map<String, Object> courseIdDictMap;

    @RelationDict(
            masterIdField = "paperId",
            slaveModelClass = TPaperInfo.class,
            slaveIdField = "id",
            slaveNameField = "title")
    @TableField(exist = false)
    private Map<String, Object> paperIdDictMap;

    @TableField(exist = false)
    private String userAnswer;

    @TableField(exist = false)
    private Integer isCorrect;

    @TableField(exist = false)
    private Double userScore;
}
